package action;

import java.io.PrintWriter;

import javax.servlet.http.HttpServletResponse;

import org.apache.struts2.ServletActionContext;

import dao.DaoFactory;
import dao.UserDao;
import entity.User;

public class Register {
	private String userName;
	private String passWord;
	private String name;
	private int age;
	private int gender;
	private String phone;
	private String validateCode;
	
	public String validateUserName() throws Exception{
		UserDao dao=DaoFactory.getInstance(UserDao.class);
		User u = dao.findByUserName(userName);
		if(u!=null){
			HttpServletResponse response = ServletActionContext.getResponse();
			response.setContentType("text/plain;charset=utf-8");
			PrintWriter out = response.getWriter();
			out.println("用户名己存在，请更换");
			out.flush();
			out.close();
		}
		return null;
	}
	
	public String getUserName() {
		return userName;
	}
	public String getPassWord() {
		return passWord;
	}
	public String getName() {
		return name;
	}
	public int getAge() {
		return age;
	}
	public int getGender() {
		return gender;
	}
	public String getPhone() {
		return phone;
	}
	public String getValidateCode() {
		return validateCode;
	}
	public void setUserName(String userName) {
		this.userName = userName;
	}
	public void setPassWord(String passWord) {
		this.passWord = passWord;
	}
	public void setName(String name) {
		this.name = name;
	}
	public void setAge(int age) {
		this.age = age;
	}
	public void setGender(int gender) {
		this.gender = gender;
	}
	public void setPhone(String phone) {
		this.phone = phone;
	}
	public void setValidateCode(String validateCode) {
		this.validateCode = validateCode;
	}
}
